package com.heng.syncUp;

import org.openjdk.jol.info.ClassLayout;

import java.util.concurrent.TimeUnit;
//锁粗化
public class SynchronizedDemo5 {
    static Object objectLock = new Object();

    public static void main(String[] args) {

        new Thread(()->{
            synchronized (objectLock){
                System.out.println("111111");
            }
            synchronized (objectLock){
                System.out.println("222222");
            }
            synchronized (objectLock){
                System.out.println("333333");
            }
            synchronized (objectLock){
                System.out.println("444444");
            }
            //底层会优化，提升系统的性能
            synchronized (objectLock){
                System.out.println("111111");
                System.out.println("222222");
                System.out.println("333333");
                System.out.println("444444");
            }
        },"t1").start();

//        try {TimeUnit.SECONDS.sleep(5);}catch (InterruptedException e) {e.printStackTrace();}
    }
}
